Auto-scroll tooltip targets into view before positioning#128
Merged
Auto-scroll tooltip targets into view before positioning#128
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
djanhjo
approved these changes
Mar 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
canTooltipFitInViewport) to predict whether the tooltip can be successfully placed after scrolling. Only when the preflight passes does it smooth-scroll the target into view and wait for the scroll to settle before positioning.showTooltipComponentis nowasyncto accommodate the scroll-and-wait cycle; all call sites and tests have been updated accordingly.Key Changes
tooltip-position-manager.tscanTooltipFitInViewport— simulates a centered viewport position for the target and checks whetherfindBestPositionwould succeed, without actually scrolling.waitForScrollSettle— pollsgetBoundingClientRect().topuntil the target's position stabilizes or a timeout (1 s) elapses.ensureTargetInView— orchestrates visibility check → preflight →scrollIntoView({ behavior: 'smooth' })→ settle wait → post-scroll visibility confirmation.message-component-manager.tsshowTooltipComponentis nowasync; callsensureTargetInViewbeforepositionTooltipand bails out early if the target cannot be brought into view.message-manager.tsawaits the now-asyncshowTooltipComponent.Tests
canTooltipFitInViewportandensureTargetInView(already visible, offscreen with successful scroll, nested scroll container, preflight failure).showTooltipComponenttests updated from sync to async.Test Plan
npm test— all existing and new tests passNote
Medium Risk
Adds new auto-scroll and preflight placement logic to tooltip rendering and makes
showTooltipComponentasync, which can change timing/behavior and introduce scroll side effects across tooltip call paths.Overview
Tooltips now auto-scroll their target into view before positioning: if the target is off-screen/clipped, the SDK runs a preflight (
canTooltipFitInViewport) and only then performs a smoothscrollIntoViewand waits for scroll to settle (ensureTargetInView).showTooltipComponentis updated toasyncand will bail out early (without callingpositionTooltip) when the target can’t be made visible;message-managerand related tests/mocks are updated toawaitthis behavior. The example page adds new demo controls/targets to exercise offscreen and scroll-container scenarios.Written by Cursor Bugbot for commit 72594d0. This will update automatically on new commits. Configure here.